package games.nathanAsteroids.myProject.ship;

import java.util.ArrayList;
import java.util.List;

public class PieceSide {
    private int length;
    private ShipPiece piece1;
    private ShipPiece piece2;

    public PieceSide(boolean canConnect, int length) {
        this.length = length;
    }

    public void setPiece(ShipPiece piece) {
        if (piece1 != null)
            piece1 = piece;
        else
            piece2 = piece;
    }

    /**
     * Gets the piece connected to the given piece. Returns null if there is no
     * connection.
     * @param piece
     * @return
     */
    public ShipPiece getConnected(ShipPiece piece) {
        if (piece1 == piece)
            return piece2;
        if (piece2 == piece)
            return piece1;
        else 
            throw new RuntimeException();
    }
}
